package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 大攻略
 */
@Getter@Setter
@AllArgsConstructor@NoArgsConstructor
@ToString
@JsonIgnoreProperties("handler")//改成json模式
public class Strategy extends BaseDomain{
    public static final int STATE_NORMAL=1;//正常
    public static final int STATE_HOT=2;//推荐
    public static final int STATE_DISABLE=3;//禁用

    private Region place;

    private String title;

    private String subTitle;

    private String coverUrl;

    private Integer state=STATE_NORMAL;

    //关联游记
    private List<Travel> travel=new ArrayList<>();

    public String getStateDisplay(){
        if(state==STATE_NORMAL){
            return "正常";
        }else if(state==STATE_NORMAL){
            return "推荐";
        }else if(state==STATE_NORMAL){
            return "禁用";
        }
        return "";
    }

    public String getJson(){
        Map<String,Object> map =new HashMap<>();
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        if(place!=null){
            map.put("placeId",place.getId());
        }
        map.put("id",getId());
        return JSONUtils.toJSONString(map);
    }

}